
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>修改 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="5.5.html" />
    
    
    <link rel="prev" href="5.3.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" >
            
                <a target="_blank" href="https://github.com/xfl03/CoreModTutor">
            
                    
                    源代码仓库（求star）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    目录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="0.html">
            
                <a href="0.html">
            
                    
                    0 绪论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    1 简介
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="1.1.html">
            
                <a href="1.1.html">
            
                    
                    CoreMod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="1.2.html">
            
                <a href="1.2.html">
            
                    
                    Java虚拟机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="1.3.html">
            
                <a href="1.3.html">
            
                    
                    Minecraft混淆方式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    2 Java虚拟机
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" >
            
                <span>
            
                    
                    ClassLoader类加载器
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" >
            
                <span>
            
                    
                    ByteCode字节码
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" >
            
                <span>
            
                    
                    ASM
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    3 原版 CoreMod
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="3.1.html">
            
                <a href="3.1.html">
            
                    
                    直接修改class文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="3.2.html">
            
                <a href="3.2.html">
            
                    
                    JavaAgent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="3.3.html">
            
                <a href="3.3.html">
            
                    
                    LaunchWrapper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="3.4.html">
            
                <a href="3.4.html">
            
                    
                    ModLauncher
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    4 FML CoreMod
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="4.1.html">
            
                <a href="4.1.html">
            
                    
                    1.3.2-1.5.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="4.2.html">
            
                <a href="4.2.html">
            
                    
                    1.6.1-1.12.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="4.3.html">
            
                <a href="4.3.html">
            
                    
                    1.13.2-1.14.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="5.html">
            
                <a href="5.html">
            
                    
                    5 Mixin
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="5.1.html">
            
                <a href="5.1.html">
            
                    
                    配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="5.2.html">
            
                <a href="5.2.html">
            
                    
                    引导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="5.3.html">
            
                <a href="5.3.html">
            
                    
                    注入
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.8.4" data-path="5.4.html">
            
                <a href="5.4.html">
            
                    
                    修改
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="5.5.html">
            
                <a href="5.5.html">
            
                    
                    定位
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="5.6.html">
            
                <a href="5.6.html">
            
                    
                    融合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="5.7.html">
            
                <a href="5.7.html">
            
                    
                    扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="5.8.html">
            
                <a href="5.8.html">
            
                    
                    调试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" >
            
                <span>
            
                    
                    附录
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="附录A.html">
            
                <a href="附录A.html">
            
                    
                    附录A 相关工具下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="附录B.html">
            
                <a href="附录B.html">
            
                    
                    附录B 常见Java字节码指令表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="附录C.html">
            
                <a href="附录C.html">
            
                    
                    附录C 参考资料
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >修改</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4FEE;&#x6539;">&#x4FEE;&#x6539;</h1>
<p>&#x9664;&#x4E86;&#x4E0A;&#x4E00;&#x7BC7;&#x4ECB;&#x7ECD;&#x7684;<code>@Overwrite</code>&#x548C;<code>@Inject</code>&#x4E4B;&#x5916;&#xFF0C;Mixin&#x8FD8;&#x63D0;&#x4F9B;&#x4E86;&#x5176;&#x4ED6;&#x7684;&#x4FEE;&#x6539;&#x65B9;&#x5F0F;</p>
<p>&#x6211;&#x4EEC;&#x8FD8;&#x662F;&#x4EE5;&#x4FEE;&#x6539;&#x6807;&#x9898;&#x4E3A;&#x4F8B;&#xFF0C;&#x7EE7;&#x7EED;&#x8003;&#x8651;&#x8FD8;&#x6709;&#x54EA;&#x4E9B;&#x53EF;&#x884C;&#x7684;&#x65B9;&#x6848;&#xFF1A;</p>
<ul>
<li><p>&#x53EF;&#x4EE5;&#x628A;<code>Display.setTitle</code>&#x66FF;&#x6362;&#x6210;&#x8C03;&#x7528;&#x81EA;&#x5DF1;&#x7684;&#x65B9;&#x6CD5;</p>
<pre><code class="lang-java">  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">createDisplay</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> LWJGLException </span>{
      Display.setResizable(<span class="hljs-keyword">true</span>);
      <span class="hljs-keyword">this</span>.mixinMethod(<span class="hljs-string">&quot;Minecraft 1.12.2&quot;</span>); <span class="hljs-comment">// &lt;--&#x6CE8;&#x610F;&#x770B;&#x8FD9;&#x91CC;</span>
      <span class="hljs-keyword">try</span> {
          Display.create((<span class="hljs-keyword">new</span> PixelFormat()).withDepthBits(<span class="hljs-number">24</span>));
      } <span class="hljs-keyword">catch</span> (LWJGLException lwjglexception) {
          LOGGER.error(<span class="hljs-string">&quot;Couldn&apos;t set pixel format&quot;</span>, lwjglexception);
          <span class="hljs-keyword">try</span> {
              Thread.sleep(<span class="hljs-number">1000L</span>);
          } <span class="hljs-keyword">catch</span> (InterruptedException e) {}
          <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.fullscreen) {
              <span class="hljs-keyword">this</span>.updateDisplayMode();
          }
          Display.create();
      }
  }

  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">mixinMethod</span><span class="hljs-params">(String title)</span> </span>{
      Display.setTitle(<span class="hljs-string">&quot;MyCustomTitle&quot;</span>);
  }
</code></pre>
<p>  &#x9488;&#x5BF9;&#x8FD9;&#x79CD;&#x4FEE;&#x6539;&#x65B9;&#x5F0F;&#xFF0C;Mixin&#x63D0;&#x4F9B;&#x4E86;&#xFF1A;</p>
<ul>
<li><p><code>@Redirect</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/injection/Redirect.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x5141;&#x8BB8;&#x6A21;&#x7EC4;&#x53D6;&#x6D88;&#x539F;&#x5148;&#x8C03;&#x7528;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x5E76;&#x91CD;&#x65B0;&#x6307;&#x5411;&#x81EA;&#x5DF1;&#x7684;&#x65B9;&#x6CD5;&#x3002;<br>&#x7528;&#x6CD5;&#x548C;<code>@Inject</code>&#x7C7B;&#x4F3C;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example.mixins;

<span class="hljs-keyword">import</span> net.minecraft.client.Minecraft;
<span class="hljs-keyword">import</span> net.minecraft.client.settings.KeyBinding;
<span class="hljs-keyword">import</span> org.apache.logging.log4j.Logger;
<span class="hljs-keyword">import</span> org.lwjgl.opengl.Display;
<span class="hljs-keyword">import</span> org.spongepowered.asm.lib.Opcodes;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.Mixin;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.At;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.Redirect;

<span class="hljs-meta">@Mixin</span>(Minecraft.class)
<span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MixinMinecraft</span> </span>{
  <span class="hljs-comment">// @Redirect &#x8981;&#x6C42; @At.value &#x53EA;&#x80FD;&#x662F; INVOKE &#x6216; FIELD</span>

  <span class="hljs-comment">// &#x5BF9;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#x548C;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x8981;&#x6C42;&#x8BE6;&#x89C1;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;:</span>
  <span class="hljs-comment">// &#x5982;&#x679C;&#x5B9A;&#x4F4D;&#x7684;&#x662F;&#x8C03;&#x7528;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x6216;&#x8005;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF08;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x88AB;&#x6784;&#x9020;&#x7684;&#x7C7B;&#x578B;&#xFF09;&#xFF1A;</span>
  <span class="hljs-comment">//   private &lt;&#x91CD;&#x5B9A;&#x5411;&#x65B9;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x7C7B;&#x578B;&gt; function(&lt;&#x91CD;&#x5B9A;&#x5411;&#x65B9;&#x6CD5;&#x7684;&#x6240;&#x6709;&#x53C2;&#x6570;&gt;)</span>
  <span class="hljs-comment">// &#x7279;&#x522B;&#x5730;&#xFF0C;&#x5F53;&#x91CD;&#x5B9A;&#x5411;&#x7684;&#x662F;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x5185;&#x7684;&#x7236;&#x7C7B;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4F20;&#x5165;&#x53C2;&#x6570;&#x4E2D;&#x7684;&#x65B9;&#x6CD5;&#x6216;&#x5B57;&#x6BB5;&#x5F15;&#x7528;&#xFF08;&#x4E0D;&#x662F;&#x91CD;&#x5B9A;&#x5411;&#x7236;&#x7C7B;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x672C;&#x8EAB;&#xFF09;&#xFF0C;&#x90A3;&#x4E48;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x5FC5;&#x987B;&#x662F;&#x9759;&#x6001;&#x7684;</span>
  <span class="hljs-comment">// &#x91CD;&#x5B9A;&#x5411;&#x7236;&#x7C7B;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x672C;&#x8EAB;&#x53C2;&#x89C1; @ModifyArgs &#x6CE8;&#x89E3;&#xFF0C; @At &#x6CE8;&#x89E3;&#x7684;&#x7528;&#x6CD5;&#x53C2;&#x89C1;&#x4E0B;&#x4E00;&#x7AE0;-&#x5B9A;&#x4F4D;</span>
  <span class="hljs-comment">// &#x548C; @Inject &#x7C7B;&#x4F3C;&#xFF0C;&#x4E0B;&#x9762;&#x6240;&#x6709;&#x60C5;&#x51B5;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x5FC5;&#x8981;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x5728;&#x53C2;&#x6570;&#x540E;&#x8FFD;&#x52A0;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;</span>
  <span class="hljs-meta">@Redirect</span>(
      method = <span class="hljs-string">&quot;createDisplay&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;INVOKE&quot;</span>, target = <span class="hljs-string">&quot;Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V&quot;</span>, remap = <span class="hljs-keyword">false</span>)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">redirect_createDisplay</span><span class="hljs-params">(String title)</span> </span>{ Display.setTitle(<span class="hljs-string">&quot;MyCustomTitle&quot;</span>); }

  <span class="hljs-comment">// &#x5982;&#x679C;&#x5B9A;&#x4F4D;&#x7684;&#x662F;&#x8C03;&#x7528;&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x3001;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;&#x6216;&#x7236;&#x7C7B;&#x65B9;&#x6CD5;&#xFF1A;</span>
  <span class="hljs-comment">//   private &lt;&#x91CD;&#x5B9A;&#x5411;&#x65B9;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x7C7B;&#x578B;&gt; function(&lt;&#x91CD;&#x5B9A;&#x5411;&#x65B9;&#x6CD5;&#x6240;&#x5728;&#x7C7B;&#x5B9E;&#x4F8B;&#x7C7B;&#x578B;&gt;, &lt;&#x91CD;&#x5B9A;&#x5411;&#x65B9;&#x6CD5;&#x7684;&#x6240;&#x6709;&#x53C2;&#x6570;&gt;)</span>
  <span class="hljs-meta">@Redirect</span>(
      method = <span class="hljs-string">&quot;createDisplay&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;INVOKE&quot;</span>, target = <span class="hljs-string">&quot;Lorg/apache/logging/log4j/Logger;error(Ljava/lang/String;Ljava/lang/Throwable;)V&quot;</span>, remap = <span class="hljs-keyword">false</span>)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">redirect_createDisplay</span><span class="hljs-params">(Logger logger, String message, Throwable t)</span> </span>{}

  <span class="hljs-comment">// &#x5982;&#x679C;&#x5B9A;&#x4F4D;&#x7684;&#x662F;&#x8BFB;&#x53D6;&#x9759;&#x6001;&#x5B57;&#x6BB5;&#xFF1A;</span>
  <span class="hljs-comment">//   private &lt;&#x5B57;&#x6BB5;&#x7C7B;&#x578B;&gt; function()</span>
  <span class="hljs-meta">@Redirect</span>(
      method = <span class="hljs-string">&quot;createDisplay&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;FIELD&quot;</span>, target = <span class="hljs-string">&quot;Lnet/minecraft/client/Minecraft;LOGGER:Lorg/apache/logging/log4j/Logger;&quot;</span>, opcode = Opcodes.GETSTATIC)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> Logger <span class="hljs-title">redirect_createDisplay</span><span class="hljs-params">()</span> </span>{ <span class="hljs-keyword">return</span> <span class="hljs-keyword">null</span>; }

  <span class="hljs-comment">// &#x5982;&#x679C;&#x5B9A;&#x4F4D;&#x7684;&#x662F;&#x5199;&#x5165;&#x9759;&#x6001;&#x5B57;&#x6BB5;&#xFF1A;</span>
  <span class="hljs-comment">//   private void function(&lt;&#x5B57;&#x6BB5;&#x7C7B;&#x578B;&gt;)</span>
  <span class="hljs-meta">@Redirect</span>(
      method = <span class="hljs-string">&quot;freeMemory&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;FIELD&quot;</span>, target = <span class="hljs-string">&quot;Lnet/minecraft/client/Minecraft;memoryReserve:[B&quot;</span>, opcode = Opcodes.PUTSTATIC)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">redirect_freeMemory</span><span class="hljs-params">(<span class="hljs-keyword">byte</span>[] memoryReserve)</span> </span>{}

  <span class="hljs-comment">// &#x5982;&#x679C;&#x5B9A;&#x4F4D;&#x7684;&#x662F;&#x8BFB;&#x53D6;&#x5B9E;&#x4F8B;&#x5B57;&#x6BB5;&#xFF1A;</span>
  <span class="hljs-comment">//   private &lt;&#x5B57;&#x6BB5;&#x7C7B;&#x578B;&gt; function(&lt;&#x5B57;&#x6BB5;&#x6240;&#x5728;&#x7C7B;&#x5B9E;&#x4F8B;&#x7C7B;&#x578B;&gt;)</span>
  <span class="hljs-meta">@Redirect</span>(
      method = <span class="hljs-string">&quot;createDisplay&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;FIELD&quot;</span>, target = <span class="hljs-string">&quot;Lnet/minecraft/client/Minecraft;fullscreen:Z&quot;</span>, opcode = Opcodes.GETFIELD)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">redirect_createDisplay</span><span class="hljs-params">(Minecraft mc)</span> </span>{ <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>; }

  <span class="hljs-comment">// &#x5982;&#x679C;&#x5B9A;&#x4F4D;&#x7684;&#x662F;&#x5199;&#x5165;&#x5B9E;&#x4F8B;&#x5B57;&#x6BB5;&#xFF1A;</span>
  <span class="hljs-comment">//   private void function(&lt;&#x5B57;&#x6BB5;&#x6240;&#x5728;&#x7C7B;&#x5B9E;&#x4F8B;&#x7C7B;&#x578B;&gt;, &lt;&#x5B57;&#x6BB5;&#x7C7B;&#x578B;&gt;)</span>
  <span class="hljs-meta">@Redirect</span>(
      method = <span class="hljs-string">&quot;run&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;FIELD&quot;</span>, target = <span class="hljs-string">&quot;Lnet/minecraft/client/Minecraft;running:Z&quot;</span>, opcode = Opcodes.PUTFIELD)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">redirect_run</span><span class="hljs-params">(Minecraft mc, <span class="hljs-keyword">boolean</span> running)</span> </span>{}

  <span class="hljs-comment">// &#x7279;&#x522B;&#x5730;&#xFF0C;&#x5982;&#x679C;&#x5B9A;&#x4F4D;&#x7684;&#x662F;&#x6570;&#x7EC4;&#x5143;&#x7D20;&#x76F8;&#x5173;&#x7684;&#x8BFB;&#x5199;&#x7684;&#x8BDD;</span>
  <span class="hljs-comment">//  &#x8BFB;&#x53D6;&#x6570;&#x7EC4;&#x5143;&#x7D20;&#xFF1A;</span>
  <span class="hljs-comment">//   private &lt;&#x6570;&#x7EC4;&#x5143;&#x7D20;&#x7C7B;&#x578B;&gt; function(&lt;&#x6570;&#x7EC4;&#x7C7B;&#x578B;&gt;, int index)</span>
  <span class="hljs-meta">@Redirect</span>(
      method = <span class="hljs-string">&quot;processKeyBinds&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;FIELD&quot;</span>, args = <span class="hljs-string">&quot;array=get&quot;</span>, target = <span class="hljs-string">&quot;Lnet/minecraft/client/settings/GameSettings;keyBindsHotbar:[Lnet/minecraft/client/settings/KeyBinding;&quot;</span>)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> KeyBinding <span class="hljs-title">redirect_processKeyBinds</span><span class="hljs-params">(KeyBinding[] keyBindsHotbar, <span class="hljs-keyword">int</span> index)</span> </span>{ <span class="hljs-keyword">return</span> <span class="hljs-keyword">null</span>; }

  <span class="hljs-comment">//  &#x5199;&#x5165;&#x6570;&#x7EC4;&#x5143;&#x7D20;&#xFF1A;&#xFF08;&#x56E0;&#x4E3A;&#x6574;&#x4E2A; Minecraft &#x7C7B;&#x4E2D;&#x6CA1;&#x6709;&#x5199;&#x5165;&#x6570;&#x7EC4;&#x5143;&#x7D20;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x6240;&#x4EE5;&#x6CA1;&#x6709;&#x53EF;&#x7528;&#x7684;&#x4F8B;&#x5B50;&#xFF09;</span>
  <span class="hljs-comment">//   private void function(&lt;&#x6570;&#x7EC4;&#x7C7B;&#x578B;&gt;, int index, &lt;&#x6570;&#x7EC4;&#x5143;&#x7D20;&#x7C7B;&#x578B;&gt;)</span>
  <span class="hljs-comment">//@Redirect(</span>
  <span class="hljs-comment">//    method = &quot;someMethod&quot;,</span>
  <span class="hljs-comment">//    at = @At(value = &quot;FIELD&quot;, args = &quot;array=set&quot;, target = &quot;LSomeClass1;someArray:[LSomeClass2;&quot;)</span>
  <span class="hljs-comment">//)</span>
  <span class="hljs-comment">//private void redirect_someMethod(SomeClass2[] someArray, int index, SomeClass2 value) {}</span>

  <span class="hljs-comment">//  &#x83B7;&#x53D6;&#x4E00;&#x7EF4;&#x6570;&#x7EC4; length &#x5C5E;&#x6027;&#xFF1A;</span>
  <span class="hljs-comment">//   private int function(&lt;&#x6570;&#x7EC4;&#x7C7B;&#x578B;&gt;)</span>
  <span class="hljs-comment">//@Redirect(</span>
  <span class="hljs-comment">//    method = &quot;someMethod&quot;,</span>
  <span class="hljs-comment">//    at = @At(value = &quot;FIELD&quot;, args = &quot;array=length&quot;, target = &quot;LSomeClass1;someArray:[LSomeClass2;&quot;)</span>
  <span class="hljs-comment">//)</span>
  <span class="hljs-comment">//private int redirect_someMethod(SomeClass2[] someArray) { return 0; }</span>

  <span class="hljs-comment">//  &#x83B7;&#x53D6;&#x591A;&#x7EF4;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x67D0;&#x4E00;&#x7EF4;&#x7684; length &#x5C5E;&#x6027;&#xFF1A;</span>
  <span class="hljs-comment">//   private int function(&lt;&#x6570;&#x7EC4;&#x7C7B;&#x578B;&gt;, int baseDim1, int baseDim2, int baseDim3, ...) &lt;-- &#x540E;&#x9762; int &#x53C2;&#x6570;&#x7684;&#x6570;&#x91CF;&#x7B49;&#x4E8E;&#x6570;&#x7EC4;&#x7EF4;&#x5EA6;&#x6570;&#x91CF;-1</span>
  <span class="hljs-comment">//@Redirect(</span>
  <span class="hljs-comment">//    method = &quot;someMethod&quot;,</span>
  <span class="hljs-comment">//    at = @At(value = &quot;FIELD&quot;, args = &quot;array=length&quot;, target = &quot;LSomeClass1;someArray:[[[LSomeClass2;&quot;)</span>
  <span class="hljs-comment">//)</span>
  <span class="hljs-comment">//private int redirect_someMethod(SomeClass2[][][] someArray, int baseDim1, int baseDim2) { return 0; }</span>
}
</code></pre>
</li>
</ul>
</li>
<li><p>&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x628A;<code>Display.setTitle</code>&#x4F20;&#x5165;&#x53C2;&#x6570;&#x5904;&#x7406;&#x4E00;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-java">  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">createDisplay</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> LWJGLException </span>{
      Display.setResizable(<span class="hljs-keyword">true</span>);
      Display.setTitle(<span class="hljs-keyword">this</span>.mixinMethod(<span class="hljs-string">&quot;Minecraft 1.12.2&quot;</span>)); <span class="hljs-comment">// &lt;--&#x6CE8;&#x610F;&#x770B;&#x8FD9;&#x91CC;</span>
      <span class="hljs-keyword">try</span> {
          Display.create((<span class="hljs-keyword">new</span> PixelFormat()).withDepthBits(<span class="hljs-number">24</span>));
      } <span class="hljs-keyword">catch</span> (LWJGLException lwjglexception) {
          LOGGER.error(<span class="hljs-string">&quot;Couldn&apos;t set pixel format&quot;</span>, lwjglexception);
          <span class="hljs-keyword">try</span> {
              Thread.sleep(<span class="hljs-number">1000L</span>);
          } <span class="hljs-keyword">catch</span> (InterruptedException e) {}
          <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.fullscreen) {
              <span class="hljs-keyword">this</span>.updateDisplayMode();
          }
          Display.create();
      }
  }

  <span class="hljs-function"><span class="hljs-keyword">private</span> String <span class="hljs-title">mixinMethod</span><span class="hljs-params">(String title)</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;MyCustomTitle&quot;</span>;
  }
</code></pre>
<p>  &#x6211;&#x4EEC;&#x5E76;&#x6CA1;&#x6709;&#x53D6;&#x6D88;&#x539F;&#x6765;&#x7684;<code>Display.setTitle</code>&#xFF0C;&#x53EA;&#x662F;&#x628A;&#x5B83;&#x7684;&#x53C2;&#x6570;&#x5904;&#x7406;&#x4E86;&#x4E00;&#x4E0B;&#x3002;<br>  Mixin&#x9488;&#x5BF9;&#x8FD9;&#x79CD;&#x4FEE;&#x6539;&#x65B9;&#x5F0F;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#xFF1A;</p>
<ul>
<li><p><code>@ModifyArg</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/injection/ModifyArg.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x5141;&#x8BB8;&#x6A21;&#x7EC4;&#x4FEE;&#x6539;&#x65B9;&#x6CD5;&#x4F20;&#x5165;&#x53C2;&#x6570;&#xFF0C;&#x7528;&#x6CD5;&#x548C;<code>@Inject</code>&#x7C7B;&#x4F3C;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example.mixins;

<span class="hljs-keyword">import</span> net.minecraft.client.Minecraft;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.Mixin;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.At;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.ModifyArg;

<span class="hljs-meta">@Mixin</span>(Minecraft.class)
<span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MixinMinecraft</span> </span>{
  <span class="hljs-comment">// @ModifyArg &#x8981;&#x6C42; @At.value &#x53EA;&#x80FD;&#x662F; INVOKE</span>
  <span class="hljs-comment">// Mixin&#x4F1A;&#x6839;&#x636E;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x81EA;&#x52A8;&#x5224;&#x65AD;&#x6A21;&#x7EC4;&#x4FEE;&#x6539;&#x7684;&#x662F;&#x54EA;&#x4E2A;&#x53C2;&#x6570;</span>
  <span class="hljs-comment">// &#x5982;&#x679C;target&#x6307;&#x5411;&#x7684;&#x76EE;&#x6807;&#x6709;&#x4E0D;&#x6B62;&#x4E00;&#x4E2A;&#x548C;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x76F8;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x53C2;&#x6570;</span>
  <span class="hljs-comment">// &#x90A3;&#x4E48;&#x9700;&#x8981;&#x6307;&#x5B9A; index &#x5C5E;&#x6027;&#xFF0C;&#x6765;&#x786E;&#x5B9A;&#x4FEE;&#x6539;&#x7684;&#x662F;&#x54EA;&#x4E2A;&#x53C2;&#x6570;</span>
  <span class="hljs-comment">// index &#x4ECE; 0 &#x5F00;&#x59CB;&#xFF0C;&#x4E14;&#x4E3A;&#x76F8;&#x540C;&#x7C7B;&#x578B;&#x53C2;&#x6570;&#x7684;&#x7D22;&#x5F15;</span>
  <span class="hljs-comment">// &#x4F8B;&#x5982;&#x67D0;&#x4E2A;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#x662F; int, int, String, int, String</span>
  <span class="hljs-comment">// &#x4F60;&#x60F3;&#x4FEE;&#x6539;&#x6700;&#x540E;&#x4E00;&#x4E2A; String &#x7C7B;&#x578B;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x90A3;&#x4E48;&#x5E94;&#x5F53;&#x5199; index = 1</span>

  <span class="hljs-comment">// &#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x9700;&#x8981;&#x548C;&#x88AB;&#x4FEE;&#x6539;&#x7684;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x4E00;&#x81F4;</span>
  <span class="hljs-comment">// &#x53C2;&#x6570;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x662F;&#xFF1A;</span>
  <span class="hljs-comment">//   &#x53EA;&#x4F20;&#x5165;&#x88AB;&#x4FEE;&#x6539;&#x7684;&#x53C2;&#x6570;</span>
  <span class="hljs-comment">//   &#x4F20;&#x5165;target&#x6307;&#x5411;&#x76EE;&#x6807;&#x7684;&#x6240;&#x6709;&#x53C2;&#x6570;</span>
  <span class="hljs-comment">//   &#x4F20;&#x5165;target&#x6307;&#x5411;&#x76EE;&#x6807;&#x7684;&#x6240;&#x6709;&#x53C2;&#x6570;&#x548C;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x7684;&#x6240;&#x6709;&#x53C2;&#x6570;</span>
  <span class="hljs-comment">// &#x5176;&#x4ED6;&#x5177;&#x4F53;&#x5185;&#x5BB9;&#x8BF7;&#x53C2;&#x8003;&#x6587;&#x6863;</span>
  <span class="hljs-meta">@ModifyArg</span>(
      method = <span class="hljs-string">&quot;createDisplay&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;INVOKE&quot;</span>, target = <span class="hljs-string">&quot;Lorg/lwjgl/opengl/Display;setTitle(Ljava/lang/String;)V&quot;</span>, remap = <span class="hljs-keyword">false</span>)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> String <span class="hljs-title">modifyArg_createDisplay</span><span class="hljs-params">(String title)</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;MyCustomTitle&quot;</span>;
  }
}
</code></pre>
</li>
</ul>
</li>
<li><p>&#x80FD;&#x4FEE;&#x6539;&#x5355;&#x4E2A;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#xFF0C;&#x81EA;&#x7136;&#x4E5F;&#x80FD;&#x4E00;&#x6B21;&#x6027;&#x4FEE;&#x6539;&#x591A;&#x4E2A;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#xFF1A;</p>
<ul>
<li><p><code>@ModifyArgs</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/injection/ModifyArgs.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x4E0D;&#x8FC7;Mixin&#x5EFA;&#x8BAE;&#x5C3D;&#x91CF;&#x4E0D;&#x8981;&#x7528;&#x5B83;&#xFF0C;&#x4E00;&#x65B9;&#x9762;&#xFF0C;&#x5927;&#x90E8;&#x5206;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x7528;<code>@Redirect</code>&#x4EE3;&#x66FF;&#xFF0C;&#x53E6;&#x4E00;&#x65B9;&#x9762;&#xFF0C;&#x7528;&#x4E86;&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#xFF0C;Mixin&#x4F1A;&#x6267;&#x884C;&#x4E00;&#x5806;&#x88C5;&#x7BB1;&#x548C;&#x62C6;&#x7BB1;&#x64CD;&#x4F5C;&#xFF0C;&#x4EE5;&#x4FBF;&#x4E8E;&#x8C03;&#x7528;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#xFF0C;&#x8FD9;&#x6837;&#x5F71;&#x54CD;&#x4EE3;&#x7801;&#x8FD0;&#x884C;&#x6548;&#x7387;&#x3002;&#x53EA;&#x6709;&#x5728;<code>@Redirect</code>&#x65E0;&#x6CD5;&#x5339;&#x914D;&#x7684;&#x540C;&#x65F6;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x624D;&#x80FD;&#x8003;&#x8651;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#x3002;<br>&#x6BD4;&#x5982;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E00;&#x5F00;&#x59CB;&#x8C03;&#x7528;&#x7684;&#x7236;&#x7C7B;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4F20;&#x5165;&#x7684;&#x591A;&#x4E2A;&#x53C2;&#x6570;&#x65F6;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example.mixins;

<span class="hljs-keyword">import</span> net.minecraft.client.gui.recipebook.GuiButtonRecipeTab;
<span class="hljs-keyword">import</span> net.minecraft.creativetab.CreativeTabs;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.Mixin;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.At;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.ModifyArgs;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.invoke.arg.Args;

<span class="hljs-meta">@Mixin</span>(GuiButtonRecipeTab.class)
<span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MixinGuiButtonRecipeTab</span> </span>{
  <span class="hljs-comment">// &#x4E0E; @ModifyArg &#x4E00;&#x6837;&#xFF0C;@ModifyArgs &#x4E5F;&#x8981;&#x6C42; @At.value &#x53EA;&#x80FD;&#x662F; INVOKE</span>
  <span class="hljs-comment">// @ModifyArgs &#x8FD8;&#x8981;&#x6C42;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x662F; void &#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x5FC5;&#x987B;&#x662F; Args &#x7C7B;&#x578B;&#xFF0C;&#x91CC;&#x9762;&#x4FDD;&#x5B58;&#x4E86;&#x76EE;&#x6807;&#x4E2D;&#x6240;&#x6709;&#x7684;&#x53C2;&#x6570;&#x7684;&#x503C;</span>
  <span class="hljs-comment">// &#x5982;&#x679C;&#x6709;&#x5FC5;&#x8981;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x4E2D;&#x8FFD;&#x52A0;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;</span>
  <span class="hljs-comment">// &#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x4FEE;&#x6539;&#x7684;&#x662F;&#x8C03;&#x7528;&#x7236;&#x7C7B;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x65F6;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x6240;&#x4EE5;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x5FC5;&#x987B;&#x662F;&#x9759;&#x6001;&#x65B9;&#x6CD5;</span>
  <span class="hljs-meta">@ModifyArgs</span>(
      method = <span class="hljs-string">&quot;&lt;init&gt;&quot;</span>,
      at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;INVOKE&quot;</span>, target = <span class="hljs-string">&quot;Lnet/minecraft/client/gui/GuiButtonToggle;&lt;init&gt;(IIIIIZ)V&quot;</span>, remap = <span class="hljs-keyword">false</span>)
  )
  <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> modifyArgs_$init$(Args args, <span class="hljs-keyword">int</span> id, CreativeTabs tabs) {
      args.set(<span class="hljs-number">3</span>, <span class="hljs-number">50</span>);
      args.set(<span class="hljs-number">4</span>, <span class="hljs-number">100</span>); <span class="hljs-comment">// &lt;-- &#x6253;&#x5F00;&#x7269;&#x54C1;&#x680F;&#x7684;&#x5408;&#x6210;&#x914D;&#x65B9;&#x754C;&#x9762;&#x5C06;&#x4F1A;&#x53D8;&#x5F97;&#x5F88;&#x9B3C;&#x755C;</span>
  }
}
</code></pre>
</li>
</ul>
</li>
<li><p>&#x7EE7;&#x7EED;&#x6211;&#x4EEC;&#x7684;&#x4FEE;&#x6539;&#x6807;&#x9898;&#x7684;&#x8BDD;&#x9898;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#xFF1A;</p>
<pre><code class="lang-java">  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">createDisplay</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> LWJGLException </span>{
      Display.setResizable(<span class="hljs-keyword">true</span>);
      String $str = <span class="hljs-keyword">this</span>.mixinMethod(<span class="hljs-string">&quot;Minecraft 1.12.2&quot;</span>); <span class="hljs-comment">// &lt;--&#x6CE8;&#x610F;&#x770B;&#x8FD9;&#x91CC;</span>
      Display.setTitle($str); 
      <span class="hljs-keyword">try</span> {
          Display.create((<span class="hljs-keyword">new</span> PixelFormat()).withDepthBits(<span class="hljs-number">24</span>));
      } <span class="hljs-keyword">catch</span> (LWJGLException lwjglexception) {
          LOGGER.error(<span class="hljs-string">&quot;Couldn&apos;t set pixel format&quot;</span>, lwjglexception);
          <span class="hljs-keyword">try</span> {
              Thread.sleep(<span class="hljs-number">1000L</span>);
          } <span class="hljs-keyword">catch</span> (InterruptedException e) {}
          <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.fullscreen) {
              <span class="hljs-keyword">this</span>.updateDisplayMode();
          }
          Display.create();
      }
  }

  <span class="hljs-function"><span class="hljs-keyword">private</span> String <span class="hljs-title">mixinMethod</span><span class="hljs-params">(String title)</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;MyCustomTitle&quot;</span>;
  }
</code></pre>
<p>  &#x867D;&#x7136;&#x8FD9;&#x6837;&#x548C;&#x524D;&#x9762;&#x90A3;&#x6837;&#x4FEE;&#x6539;&#x53EF;&#x80FD;&#x770B;&#x4E0D;&#x51FA;&#x4EC0;&#x4E48;&#x5DEE;&#x522B;&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x60F3;&#x66F4;&#x52A0;&#x5F3A;&#x8C03;&#x8FD9;&#x662F;&#x4FEE;&#x6539;&#x5B57;&#x7B26;&#x4E32;&#x5E38;&#x91CF;&#x672C;&#x8EAB;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4FEE;&#x6539;<code>setTitle</code>&#x65B9;&#x6CD5;&#x3002;Mixin&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x4FEE;&#x6539;&#x65B9;&#x6CD5;&#x4F53;&#x5185;&#x5E38;&#x91CF;&#x7684;&#x6CE8;&#x89E3;&#xFF1A;</p>
<ul>
<li><p><code>@ModifyConstant</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/injection/ModifyConstant.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#x53EF;&#x4EE5;&#x7528;&#x4E8E;&#x4FEE;&#x6539;&#x4F7F;&#x7528;<code>LDC</code>&#x3001;<code>*CONST_*</code>&#x3001;<code>*IPUSH</code>&#x7B49;&#x64CD;&#x4F5C;&#x7801;&#x5F15;&#x7528;&#x7684;&#x5E38;&#x91CF;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example.mixins;

<span class="hljs-keyword">import</span> net.minecraft.client.Minecraft;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.Mixin;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.Constant;
<span class="hljs-keyword">import</span> org.spongepowered.asm.mixin.injection.ModifyConstant;

<span class="hljs-meta">@Mixin</span>(Minecraft.class)
<span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MixinMinecraft</span> </span>{
  <span class="hljs-comment">// &#x548C; @ModifyArg &#x7C7B;&#x4F3C;&#xFF0C;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x548C;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x548C;&#x5339;&#x914D;&#x7684;&#x5E38;&#x91CF;&#x4E00;&#x81F4;</span>
  <span class="hljs-comment">// &#x5982;&#x679C;&#x6709;&#x5FC5;&#x8981;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x5728;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x4E2D;&#x8FFD;&#x52A0;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;</span>
  <span class="hljs-meta">@ModifyConstant</span>(
      method = <span class="hljs-string">&quot;createDisplay&quot;</span>,
      constant = <span class="hljs-meta">@Constant</span>(stringValue = <span class="hljs-string">&quot;Minecraft 1.12.2&quot;</span>)
  )
  <span class="hljs-function"><span class="hljs-keyword">private</span> String <span class="hljs-title">modifyConstant_createDisplay</span><span class="hljs-params">(String title)</span> </span>{
      <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;MyCustomTitle&quot;</span>;
  }
}
</code></pre>
</li>
<li><p><code>@Constant</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/injection/Constant.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x5C5E;&#x6027;&#xFF1A;</p>
<ul>
<li><code>intValue</code>: &#x53EF;&#x4EE5;&#x5339;&#x914D;<code>byte</code>&#x3001;<code>char</code>&#x3001;<code>int</code>&#x3001;<code>short</code>&#x7C7B;&#x578B;&#x7684;&#x5E38;&#x91CF;</li>
<li><code>expandZeroConditions</code>: &#x53C2;&#x8003;<a href="5.5.html">&#x5B9A;&#x4F4D;</a>&#x4E00;&#x7AE0;&#x7684;<code>&#x5E38;&#x91CF;&#x5F15;&#x7528;&#x7279;&#x6B8A;&#x60C5;&#x51B5;&#xFF1A;&#x4E0E;0&#x6BD4;&#x8F83;</code>&#x4E00;&#x8282;</li>
</ul>
</li>
</ul>
</li>
<li><p>&#x80FD;&#x4FEE;&#x6539;&#x5E38;&#x91CF;&#xFF0C;&#x81EA;&#x7136;&#x4E5F;&#x80FD;&#x4FEE;&#x6539;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#xFF1A;</p>
<ul>
<li><p><code>@ModifyVariable</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/injection/ModifyVariable.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#x7528;&#x4E8E;&#x4FEE;&#x6539;&#x65B9;&#x6CD5;&#x4F53;&#x5185;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#xFF0C;&#x6CE8;&#x5165;&#x70B9;&#x5FC5;&#x987B;&#x5728;&#x88AB;&#x4FEE;&#x6539;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#x4E4B;&#x4E2D;&#x3002;</p>
<ul>
<li><code>print</code>: &#x7528;&#x4E8E;&#x6307;&#x5B9A;&#x662F;&#x5426;&#x6253;&#x5370;&#x6307;&#x5B9A;&#x7C7B;&#x578B;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x8868;&#xFF08;&#x548C;<code>@Inject.locals</code>&#x7684;&#x6253;&#x5370;&#x529F;&#x80FD;&#x7C7B;&#x4F3C;&#xFF09;</li>
<li><code>ordinal</code>: &#x7528;&#x4E8E;&#x6307;&#x5B9A;&#x5728;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x8868;&#x4E2D;&#x76F8;&#x540C;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#x7684;&#x7D22;&#x5F15;&#xFF0C;&#x4ECE;0&#x5F00;&#x59CB;</li>
<li><code>index</code>: &#x7528;&#x4E8E;&#x6307;&#x5B9A;&#x5728;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x8868;&#x4E2D;&#x7684;&#x7D22;&#x5F15;&#xFF0C;&#x4ECE;0&#x5F00;&#x59CB;</li>
<li><code>name</code>: &#x7528;&#x4E8E;&#x6307;&#x5B9A;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x540D;&#x79F0;</li>
<li><p><code>argsOnly</code>: &#x662F;&#x5426;&#x53EA;&#x5339;&#x914D;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x4E0D;&#x5339;&#x914D;&#x65B9;&#x6CD5;&#x4F53;&#x5185;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;</p>
<p><code>ordinal</code>&#x3001;<code>index</code>&#x3001;<code>name</code>&#x4E09;&#x4E2A;&#x5C5E;&#x6027;&#x53EA;&#x9700;&#x8981;&#x586B;&#x4E00;&#x4E2A;&#x5373;&#x53EF;&#x3002;<br>&#x4F8B;&#x5982;&#x6709;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x8868;&#x53C2;&#x6570;&#x5206;&#x522B;&#x662F; <code>int</code>&#x3001;<code>int</code>&#x3001;<code>String</code>&#x3001;<code>int</code>&#x3001;<code>String</code>&#xFF0C;&#x4F60;&#x60F3;&#x4FEE;&#x6539;&#x6700;&#x540E;&#x4E00;&#x4E2A;<code>String</code>&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x90A3;&#x4E48;&#x53EA;&#x9700;&#x8981;&#x8BBE;&#x7F6E; <code>oridinal = 1</code> &#x6216;&#x8005; <code>index = 4</code> &#x5373;&#x53EF;&#x3002;<br>&#x548C;<code>@Inject.locals</code>&#x4E00;&#x6837;&#xFF0C;Mixin&#x5EFA;&#x8BAE;&#x5148;&#x8BBE;&#x7F6E;<code>print</code>&#x5C5E;&#x6027;&#x4E3A;<code>true</code>&#xFF0C;&#x6253;&#x5370;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x8868;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x5B8C;&#x6210;&#x53C2;&#x6570;&#x7684;&#x786E;&#x5B9A;&#x3002;&#x5F53;<code>print</code>&#x4E3A;<code>true</code>&#x65F6;&#xFF0C;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x5E76;&#x4E0D;&#x4F1A;&#x6CE8;&#x5165;&#x5230;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x4E2D;&#x53BB;&#x3002;<br>&#x4EE5;&#x4FEE;&#x6539;&#x7A97;&#x4F53;16x16&#x7684;&#x56FE;&#x6807;&#x4E3A;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-comment">// @ModifyVariable &#x6CA1;&#x6709;&#x9650;&#x5236; @At.value &#x7684;&#x53D6;&#x503C;</span>
<span class="hljs-comment">// &#x4E0E;&#x5176;&#x4ED6;&#x4FEE;&#x6539;&#x65B9;&#x5F0F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x662F;&#xFF0C; @ModifyVariable &#x6807;&#x8BB0;&#x7684;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x4E0D;&#x80FD;&#x9644;&#x5E26;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;</span>
<span class="hljs-comment">// &#x53C2;&#x6570;&#x53EA;&#x80FD;&#x6709;&#x4E00;&#x4E2A;&#xFF0C;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x548C;&#x8FD4;&#x56DE;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x4E0E;&#x88AB;&#x4FEE;&#x6539;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x4E00;&#x81F4;</span>
<span class="hljs-meta">@ModifyVariable</span>(
  method = <span class="hljs-string">&quot;setWindowIcon&quot;</span>,
  at = <span class="hljs-meta">@At</span>(value = <span class="hljs-string">&quot;INVOKE&quot;</span>, target = <span class="hljs-string">&quot;Lorg/lwjgl/opengl/Display;setIcon([Ljava/nio/ByteBuffer;)I&quot;</span>, remap = <span class="hljs-keyword">false</span>),
  ordinal = <span class="hljs-number">0</span>
)
<span class="hljs-function"><span class="hljs-keyword">private</span> InputStream <span class="hljs-title">modifyVariable_setWindowIcon</span><span class="hljs-params">(InputStream inputStream)</span> </span>{
  <span class="hljs-comment">// ...</span>
  <span class="hljs-keyword">return</span> inputStream;
}
</code></pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>&#x6709;&#x7684;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x4E3A;&#x4E86;&#x6A21;&#x7EC4;&#x7684;&#x517C;&#x5BB9;&#x6027;&#x4E4B;&#x7C7B;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x4FEE;&#x6539;&#x4E00;&#x4E9B;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x8FD0;&#x884C;&#x65F6;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x76F4;&#x63A5;&#x6307;&#x5B9A;&#x6CE8;&#x89E3;&#x7684;<code>method</code>&#x800C;&#x4E0D;&#x505A;&#x5176;&#x4ED6;&#x64CD;&#x4F5C;&#xFF0C;&#x90A3;&#x4E48;&#x7F16;&#x8BD1;&#x65F6;&#x4F1A;&#x51FA;&#x9519;&#xFF0C;&#x63D0;&#x793A;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#xFF0C;Mixin&#x63D0;&#x4F9B;&#x4E86;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#xFF1A;</p>
<ul>
<li><code>@Dynamic</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/Dynamic.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x7528;&#x4E8E;&#x6807;&#x8BB0;&#x90A3;&#x4E9B;&#x8981;&#x6CE8;&#x5165;&#x5230;&#x7F16;&#x8BD1;&#x65F6;&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x65B9;&#x6CD5;&#x7684;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x3002;</li>
</ul>
<p>&#x6709;&#x7684;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x7684;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;&#x5B58;&#x5728;&#x975E;&#x516C;&#x6709;&#x7C7B;&#x578B;&#xFF0C;&#x663E;&#x7136;&#x6211;&#x4EEC;&#x4E0D;&#x5927;&#x53EF;&#x80FD;&#x5728;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x4E2D;&#x5F15;&#x7528;&#x5B83;&#xFF0C;&#x56E0;&#x6B64;Mixin&#x63D0;&#x4F9B;&#x4E86;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#xFF1A;</p>
<ul>
<li><code>@Coerce</code>&#xFF08;<a href="http://jenkins.liteloader.com/job/Mixin/javadoc/org/spongepowered/asm/mixin/injection/Coerce.html" target="_blank">&#x6587;&#x6863;</a>&#xFF09;<br>&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#x6807;&#x8BB0;&#x5728;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#x4E0A;&#x3002;&#x5BF9;&#x4E8E;&#x5F15;&#x7528;&#x7C7B;&#x578B;&#x800C;&#x8A00;&#xFF0C;&#x7528;&#x4E8E;&#x6307;&#x793A;&#x8FD9;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x7C7B;&#x578B;&#x662F;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x5BF9;&#x5E94;&#x53C2;&#x6570;&#x7684;&#x7C7B;&#x578B;&#x7684;&#x8D85;&#x7C7B;&#xFF08;&#x53EA;&#x80FD;&#x662F;&#x8D85;&#x7C7B;&#xFF0C;&#x4E0D;&#x80FD;&#x662F;&#x63A5;&#x53E3;&#xFF0C;&#x5982;&#x679C;&#x76EE;&#x6807;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x662F;&#x975E;&#x516C;&#x6709;&#x63A5;&#x53E3;&#xFF0C;&#x90A3;&#x4E48;&#x6CE8;&#x5165;&#x65B9;&#x6CD5;&#x5BF9;&#x5E94;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x53EA;&#x80FD;&#x662F;<code>Object</code>&#xFF09;&#xFF0C;&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#x5BF9;<code>@Inject</code>&#x548C;<code>@ModifyVariable</code>&#x6355;&#x83B7;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#x4E5F;&#x662F;&#x53EF;&#x7528;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x8FD9;&#x4E2A;&#x6CE8;&#x89E3;&#x4E0D;&#x80FD;&#x7528;&#x4E8E;<code>@Surrogate</code>&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x53C2;&#x6570;&#x3002;</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="5.3.html" class="navigation navigation-prev " aria-label="Previous page: 注入">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="5.5.html" class="navigation navigation-next " aria-label="Next page: 定位">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"修改","level":"1.8.4","depth":2,"next":{"title":"定位","level":"1.8.5","depth":2,"path":"5.5.md","ref":"5.5.md","articles":[]},"previous":{"title":"注入","level":"1.8.3","depth":2,"path":"5.3.md","ref":"5.3.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"5.4.md","mtime":"2019-09-08T00:42:29.873Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-08T04:47:05.818Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

